<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Stimulus360.Controllers.Ideas.IdeasSearchViewModel>" %>
<%@ Import Namespace="Stimulus360.Models.Data" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<%
    SearchCriteria  criteria =(SearchCriteria) Enum.Parse(typeof (SearchCriteria), Model.SearchCriteria);
    var heading =criteria.Description() ;
    heading = heading + Model.SearchString;
     %>
    
    <!-- Main Area Start -->
    <div class="main">
        <div class="contetTittle">
            <div class="floatLeft">
                <a href="#" class="headerLabel"><span><%=heading%></span></a>
            </div>
            <div class="floatRight">
                <a href="/Ideas/New" class="headerLabelBtn"><span>
                    <%= Html.Image("submitIdeas.png", "") %>
                    Submit Ideas</span></a>
            </div>
        </div>
        <div id="searchListContainer">
            <%Html.RenderPartial("IdeasList", Model.Ideas); %>
        </div>
        <div class="pagerbg">
            <div id="pagerSearchIdeaList" class="pager">
            </div>
        </div>
    </div>
    <!-- Main Area End -->
    <!-- Right Col Start -->
    <div class="rightCol">
        <%Html.RenderPartial("IdeaSearch"); %>
        <%Html.RenderPartial("IdeasTagCloud", Model.Categories); %>
        <%Html.RenderPartial("IdeaRSSTagCloud"); %>
    </div>
    <!-- Right Col Start -->

    <script type="text/javascript" language="javascript">
        $(document).ready(function() {
            var criteria = "<%=Model.SearchCriteria %>";
            if (criteria == "Search") {
                $("#query").val("<%=Model.SearchString %>");
            }
            else {
                $("#query").val("<%=Model.SearchCriteria %>" + ": " + "<%=Model.SearchString %>");
            }
            var totalPages_Idea = "<%=Model.Ideas.TotalPages %>";
            if (totalPages_Idea == 1) {
                $(".pagerbg").hide();
            }
            var totalCount = "<%=Model.Ideas.TotalCount %>";
            if (totalCount == 0) {
                $(".pagerbg").hide();
            }
            
            var currentPage = "<%=Model.Ideas.PageIndex%>";

            $("#pagerSearchIdeaList").pager({ pagenumber: currentPage, pagecount: totalPages_Idea, buttonClickCallback: PageClick_SearchIdeaList });
        });
            PageClick_SearchIdeaList = function(pageclickednuber) {
                var pageIndex = pageclickednuber;
                var criteria = "<%=Model.SearchCriteria %>";
                var searchString = "<%=Model.SearchString%>";
                window.location = "/Ideas/Search/" + criteria.toString() + "/" + searchString.toString() + "/Page/" + pageIndex.toString();
            }
    </script>

</asp:Content>
